home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 145
/
Gekkan Dennou Club - 2000.6 Vol. 145 (Japan).7z
/
Gekkan Dennou Club - 2000.6 Vol. 145 (Japan) (Track 1).bin
/
ikap
/
etc
/
f56
/
f56type.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-05-08
|
4KB
|
253 lines
/*
「5x6ドットビットマップフォントを使ってファイル内容をタイプ
*/
#include <stdio.h>
#include <graph.h>
asm("
_F56pat:
.INSERT likap.f56
");
extern unsigned int F56pat[];
/* データゲット
パターン
*/
int FNTGET56(code,adr)
int code;
unsigned char *adr;
{
typedef struct {
int start,end;
} CODEBAND;
int a,area,cnum;
static int dbcnt=280;
CODEBAND codeband[8]={
{ 0x8140, 0x819e },
{ 0x819f, 0x81fc },
{ 0x8240, 0x829e },
{ 0x829f, 0x82fc },
{ 0x8340, 0x839e },
{ 0x839f, 0x83fc },
{ 0x8440, 0x849e },
{ 0x849f, 0x84fc }
};
for( a=0; a<8; a++ ){
if( codeband[a].start<=code && code<=codeband[a].end ){
area=a;
cnum=code-codeband[a].start;
if( a%2==0 && (code&0xff)>=0x80 ){
cnum-=1;
}
goto next;
}
}
area=0;
cnum=0;
next:
*(int *)adr=F56pat[area*94+cnum];
//printf("%d/%d\n",area,cnum);
}
/*
addrから格納されている5x6ドットビットマップを指定座標からに表示
*/
int FNTPUT56(fx,fy,addr)
int fx,fy;
unsigned char *addr;
{
int x,y,b,pat;
pat=*(int *) (addr);
b=31;
for( y=0; y<6; y++ ){ ; for( x=0; x<5; x++ ){
if( (pat&(1<<b)) ){
pset(fx+x,fy+y,0xf); //
}
b--;
}}
return(0);
}
/*
addrから格納されている5x6ドットビットマップを指定座標からに表示
全部×Nのオーダーで扱う
*/
int FNTPUT56big(fx,fy,addr,N)
int fx,fy;
unsigned char *addr;
int N; //拡大倍率
{
int x,y,b,pat;
pat=*(int *) (addr);
b=31;
for( y=0; y<6; y++ ){ ; for( x=0; x<5; x++ ){
if( (pat&(1<<b)) ){
// pset(fx+x,fy+y,0xf); //
fill((fx+x)*N,(fy+y)*N,(fx+x+1)*N-1,(fy+y+1)*N-1,0x0f); //
}
b--;
}}
return(0);
}
/* タブスペース変換:変換後のバイト数を返す
0d,0aとばす
*/
int detab(src,dest)
unsigned char *src,*dest;
{
unsigned char *s,*d;
short x,i,m;
s=src;
d=dest;
x=0;
while( *s ){
switch( *s ){
case '\t':
m=x%8;
if( m==0 ){ m=8; }
for( i=0; i<m; i++ ){
*d++=' ';
x++;
}
break;
case '\x0d':
case '\x0a':
;//とばし
break;
default:
*d++=*s;
x++;
break;
}
s++;
}
*d=0;
return(x);
}
int main(argc,argv)
int argc;
char *argv[];
{
#define BUFSIZE (256)
unsigned char srcbuf[BUFSIZE],destbuf[BUFSIZE]; //@@いいかげん
unsigned char typefile[128];
int x,y,xlen,w,px;
FILE *fp;
// int swidth=96,sheight=72; //F502i
int swidth=32,sheight=32; //ぽけすて
int drawoffset_x=0,drawoffset_y=16; //描画開始位置
int N=4; //拡大率
int ac;
int code;
unsigned char fntbuf[4];
for( ac=1; ac<argc; ac++ ){
if( argv[ac][0]=='/' || argv[ac][0]=='-' ){ ; switch( argv[ac][1] ){
case 'w': case 'W':
sscanf(&argv[ac][2],"%d,%d",&swidth,&sheight);
break;
case 'o': case 'O':
sscanf(&argv[ac][2],"%d,%d",&drawoffset_x,&drawoffset_y);
break;
case 'b': case 'B':
sscanf(&argv[ac][2],"%d",&N);
break;
}}
else{
//オープンファイル名
strcpy(typefile,argv[ac]);
}
}
screen(2,0,1,1);
window(0,0,767,511);
apage(0);
vpage(0xf);
{
fp=fopen(typefile,"rt");
if( fp==NULL ){
printf(
"5x6ドットフォントを使ったテキストファイル表示(type)\n"
"usage : f56type typefile [option]\n"
"option: /Ww,h 表示領域サイズの設定(def:/W32,32)\n"
" : /Ox,y 描画開始位置の設定(def:/O0,16)\n"
" : /Bn 拡大表示(def=4:0の時拡大表示なし)\n"
);
goto quick_exit;
}
}
x=0;
y=0;
while( feof(fp)==0 ){
fgets(srcbuf,BUFSIZE,fp);
if( srcbuf[0]=='\n' ){
goto next;
}
xlen=detab(srcbuf,destbuf);
x=0;
px=0;
while(1){
for( px=0; px<(swidth-6); ){
if( destbuf[x]==0 ){ goto next; }
if( 0x81<=destbuf[x] && destbuf[x]<=0x84 ){
code=0;
code=(destbuf[x]<<8)|destbuf[x+1];
x++;
FNTGET56(code,fntbuf);
FNTPUT56(px+drawoffset_x,y*7+drawoffset_y,fntbuf);
if( N ){ FNTPUT56big(px+drawoffset_x,y*7+drawoffset_y,fntbuf,N); }
}
px+=6;
x++;
}
if( destbuf[x]==0 ){ break; }
y++;
if( y>=(sheight/7) ){ break; }
}
next:
y++;
if( y>=(sheight/7) ){ break; }
}
{
fclose(fp);
}
quick_exit:
return(0);
}